package pers.cz.util;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @program: PostGirl-panent
 * @description: 主要用来获取IP地址
 * @author: Cheng Zhi
 * @create: 2022-10-18 21:19
 **/
public class NetUtils {

    /**
     * 获取本地ip地址
     * @return
     */
    public static String getLocalIp() {

        String ip = "127.0.0.1";
        try {
            InetAddress localHost = InetAddress.getLocalHost();
            ip = localHost.getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

        return ip.trim();
    }
}
